%this includes the weights of the nodes into consideration before deciding
%on a path

clc;
clear all;

v = [1 2 3 4 5 6];

u = perms(v);


u7 = [u u(:,1)];

N = 10000;

A = [N 12  N  N  9 16;
    12  N 19 12  N 15;
     N 19  N 21  N 17; 
     N 12 21  N 10 16;
     9  N  N 10  N 10;
    16 15 17 16 10  N];


%% TRP solution exhausive

%weights
q = [1 4 5 1 2 5]; % randomly generated

%q = [1 1 1 1 1 1];
%u7 = [1 5 4 2 3 6 1];

%u7 = [1     6     5     4     3     2     1];

qleft = sum(q);
for i=1:length(u7(:,1))
    s(i) = 0;    
    qdone = 0;
    for j=1:6 
        qdone = qdone + q(u7(i,j));
        index1 = u7(i,j);
        index2 = u7(i,j+1);
        multiplier = A(u7(i,j),u7(i,j+1));
        multiplied = (qleft-(qdone-q(u7(i,1))));
        s(i) = s(i) + (qleft-(qdone-q(u7(i,1))))*A(u7(i,j),u7(i,j+1));
    end
end
[smin,sminindex] = min(s(601:720));
smin
sequence = u7(600+sminindex,:)
